<?php

class Application_Model_IdeaMapper extends Application_Model_Mapper
{

    public function __construct()
    {
        parent::__construct(new Application_Model_DbTable_Tasks(), new Application_Model_Task());
    }

    public function getCollection($where = array(), $order = '', $limit = array())
    {
        $tasks = parent::getCollection($where, $order, $limit);
        usort($tasks, function ($a, $b) {
            /**
             * @var $a Application_Model_Task
             * @var $b Application_Model_Task
             */
            if ($a->getTaskPriority() > $b->getTaskPriority()) {
                return -1;
            }
            if ($a->getTaskPriority() < $b->getTaskPriority()) {
                return 1;
            }

            return 0;
        });
        return $tasks;
    }
}